package com.systemdevelopment.mainproject.Controller;


import com.systemdevelopment.mainproject.Model.Book;
import com.systemdevelopment.mainproject.Model.BorrowRecord;
import com.systemdevelopment.mainproject.Model.User;
import com.systemdevelopment.mainproject.View.mainUI;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.Set;


public class NormalUserController extends VisitorController {

    public NormalUserController() {
    }
    public NormalUserController(User u) {
        super(u);
    }

    public void borrowBook(Book book,int days) {
        try{
            BorrowRecord.Borrow(user.Account, mainUI.CurBook.getISBN(), LocalDate.now(),LocalDate.now().plusDays(days));
        }catch (Exception e){
            e.printStackTrace();
        }
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("结果");
        alert.setHeaderText("借阅成功");
        alert.setContentText("您已成功完成《"+book.getName()+"》的订阅");
        //alert.getButtonTypes().set(1,new ButtonType("cancel", ButtonBar.ButtonData.CANCEL_CLOSE));
        alert.showAndWait();
    }


    public boolean changePassword(String newPassword) {
        return false;
    }

    public Set<BorrowRecord> showBorrowRecord() {
        return null;
    }//在数据库BrrowRecord表中插入一行数据

    public void test() {
        System.out.println("NormalUserController");
    }
}